CC		= g++

SRCEXTS	= .cpp
HDREXTS	= .h

CFLAGS	= -g -O2 -Wall `pkg-config --cflags opencv` -Iinclude -std=c++0x
LDFLAGS	= `pkg-config --libs opencv` -lm  

SRCDIRS	= src
OBJDIR	= bin
INCDIR	= include

PROGRAM = steganography

SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
HEADERS = $(foreach d,$(INCDIR),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
OBJS    = $(addsuffix .o, $(addprefix $(OBJDIR)/, $(basename $(SOURCES))))

.PHONY: all objs clean clean_all show exec
.SUFFIXES:

all: $(PROGRAM) 

objs: $(OBJS)

$(OBJDIR)/%.o:%.cpp $(HEADERS)
	mkdir $(dir $@) -p
	$(CC) -c $< -o $@ $(CFLAGS)
	
$(PROGRAM): $(OBJS)
	$(CC) $(OBJS) -o $(OBJDIR)/$@ $(LDFLAGS)
	@echo Type ./$(OBJDIR)/$@ to execute the program.
	
clean:
	rm -R $(OBJDIR)/$(SRCDIR)
	
clean_all:
	rm -R $(OBJDIR)
	
exec:
	./$(OBJDIR)/$(PROGRAM)

show:
	@echo 'PROGRAM     :' $(PROGRAM)
	@echo 'SRCDIRS     :' $(SRCDIRS)
	@echo 'OBJDIR      :' $(OBJDIR)
	@echo 'SOURCES     :' $(SOURCES)
	@echo 'HEADERS     :' $(HEADERS)
	@echo 'OBJS        :' $(OBJS)
	@echo 'DEPS        :' $(DEPS)
	@echo 'CFLAGS      :' $(CFLAGS)
	@echo 'LIBS        :' $(LIBS)